package dom;

import java.util.Date;
import java.text.SimpleDateFormat;

/**
 * Represents an alert from our teachers snort database 
 * @author Alex
 */
public class Alert {

	private Date timestamp;
	private int sid;
	private int cid;
	private int sig_id;
	private int sig_sid; // matches with what is in the database
	private String sig_name;
	private long ip_src;
	private int port_src;
	private long ip_dst;
	private int port_dst;
	
	public Alert(Date timestamp, int sid, int sig_id, int sig_sid,int cid, String sig_name, long ip_src, long ip_dst){
		this.timestamp = timestamp;
		this.sid = sid;
		this.cid = cid;
		this.sig_id = sig_id;
		this.sig_sid = sig_sid;
		this.sig_name = sig_name;
		this.ip_src = ip_src;
		this.ip_dst = ip_dst;
	}
	
	public Alert(Date timestamp, int sid, int sig_id, int sig_sid,int cid, String sig_name, long ip_src, int port_src, long ip_dst, int port_dst){
		this.timestamp = timestamp;
		this.sid = sid;
		this.cid = cid;
		this.sig_id = sig_id;
		this.sig_sid = sig_sid;
		this.sig_name = sig_name;
		this.ip_src = ip_src;
		this.port_src = port_src;
		this.ip_dst = ip_dst;
		this.port_dst = port_dst;
	}
	
	public Date getTimestamp() {
		return timestamp;
	}
	public void setTimestamp(Date timestamp) {
		this.timestamp = timestamp;
	}
	public int getSid() {
		return sid;
	}
	public void setSid(int sid) {
		this.sid = sid;
	}
	public int getSig_id() {
		return sig_id;
	}
	public void setSig_id(int sig_id) {
		this.sig_id = sig_id;
	}
	public String getSig_name() {
		return sig_name;
	}
	public void setSig_name(String sig_name) {
		this.sig_name = sig_name;
	}
	public long getIp_src() {
		return ip_src;
	}
	public void setIp_src(long ip_src) {
		this.ip_src = ip_src;
	}
	public long getIp_dst() {
		return ip_dst;
	}
	public void setIp_dst(long ip_dst) {
		this.ip_dst = ip_dst;
	}
	
	public int getPort_src() {
		return port_src;
	}

	public void setPort_src(int port_src) {
		this.port_src = port_src;
	}

	public int getPort_dst() {
		return port_dst;
	}

	public void setPort_dst(int port_dst) {
		this.port_dst = port_dst;
	}

	public int getCid() {
		return cid;
	}

	public void setCid(int cid) {
		this.cid = cid;
	}

	public int getSig_sid() {
		return sig_sid;
	}

	public void setSig_sid(int sig_sid) {
		this.sig_sid = sig_sid;
	}

	@Override
	public String toString() {
		StringBuilder sb = new StringBuilder();
		SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		sb.append("====ALERT=====================\n");
		sb.append("Signature name:\t" + sig_name + "\n");
		sb.append("Timestamp:\t" + formatter.format(timestamp) + "\n");
		sb.append("Signature ID:\t" + sid + "\n");
		sb.append("Signature SID:\t" + sig_sid + "\n");
		sb.append("SID:\t\t" + sid + "\n");
		sb.append("CID:\t\t" + cid + "\n");
		sb.append("IP SOURCE:\t" + ip_src + "\n");
		sb.append("PORT SOURCE:\t" + port_src + "\n");
		sb.append("IP DESTINATION:\t" + ip_dst + "\n");
		sb.append("PORT DESTINATION:\t" + port_dst + "\n");
		sb.append("==============================\n");
		return sb.toString();
	}
	
}
